package com.csw;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

//修改mysql
public class updateMysql {
    public static void main(String[] args) throws Exception{
        //1.加载第三方工具
        Class.forName("com.mysql.jdbc.Driver");
        //2.获取连接
        String url="jdbc:mysql://master:3306/csw";
        String username="root";
        String password="123456";
        Connection connection = DriverManager.getConnection(url, username, password);
        //3.获取执行器
        Statement statement = connection.createStatement();
        String sql="update student set age=21 where sid=1001";
        //4.判断结果 1表示true 0表示false
         int i = statement.executeUpdate(sql);
        System.out.println(i);
        //关闭连接
        statement.close();
        connection.close();
    }
}
